package 前缀和;

import java.util.Scanner;

public class DP34模板前缀和1 {
    //https://www.nowcoder.com/practice/acead2f4c28c401889915da98ecdc6bf
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        int[] array = new int[n + 1];
        for(int i = 1;i <= n;i++) array[i] = in.nextInt();

        // 所有前缀和累积算出
        long[] dp = new long[n + 1];
        for(int i = 1;i <= n;i++) dp[i] = dp[i - 1] + array[i];

        while(m > 0) {
            int l = in.nextInt(), r = in.nextInt();
            System.out.println(dp[r] - dp[l - 1]);
            m--;
        }
    }
}
